﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/Dialog.Master" AutoEventWireup="true" CodeBehind="PayrollDateDialogbox.aspx.cs" Inherits="Legazpi.Payroll.Web.PopupBoxes.PayrollDateDialogbox" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script type="text/javascript">
    var serviceUrl = '<%=ResolveUrl("~/Webservices/PayrollWebService.asmx")%>';
    $(document).ready(function () {
        $('#PaydateSubmitButton').click(function () {
            if (!$("#dialogForm").valid()) {
                return false;
            }
            var json = JSON.stringify({ sPayDate: $('#Paydate').val() });
            BlockUI.BlockElementLoading("dialog", "Saving...", true, 4);
            $.ajax({
                type: "POST",
                url: serviceUrl + "/AddPayrollDate",
                data: json,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    var response = eval('(' + data.d + ')');
                    if (response.Success) {
                        alert('Saved!');
                        PopUpDialog.CloseDialog(Paydate.PaydateUpdatePopUpId);
                        location.reload(true);
                    } else {
                        alert(response.Message);                        
                    }
                },
                complete: function () {
                    BlockUI.UnBlockElement("dialog");
                }
            });
        });

        $("#Paydate").datepicker();
        $("#dialogForm").validate({
            rules: {
                Paydate: "required"
            },
            messages: {
                Paydate: "Please enter Paydate"
            }
        });
    });
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
            <form id="dialogForm">
            <fieldset class="register">
                <legend>Payroll Initialization</legend>
                <p>
                    <label for="Paydate">Enter New Paydate:</label>
                    <input type="text" id="Paydate" name="Paydate" class="textEntry" />                   
                </p>
                <p>
                    <label for="PayrollPeriod">Payroll Period: <%=strPayrollPeriod%> </label>                    
                </p>
                <%if (PreviousPaydate != null)
                  {%>
                    <p>
                        <label for="PreviousPayroll">Previous Payroll:</label>
                        <input type="text" id="PreviousPayroll" readonly="readonly" class="textEntry" value="<%=PreviousPaydate.Paydate.ToShortDateString() %>" />
                    </p>
                <%} %>
            </fieldset>
            <p class="submitButton">
                <input type="button" id="PaydateSubmitButton" value="OK" />
            </p>
            </form>
</asp:Content>
